<template>
  <el-dialog
    title="手动创建案件"
    :visible.sync="visible"
    :close-on-click-modal="false"
    :modal-append-to-body="false"
    width="40%"
  >
    <el-form
      class="small-space"
      :model="createdItem"
      label-position="right"
      label-width="100px"
    >
      <el-form-item label="案件标题">
        <el-input
          size="small"
          v-model="createdItem.title"
          placeholder
        ></el-input>
      </el-form-item>

      <el-form-item label="案件描述">
        <el-input
          size="small"
          type="textarea"
          rows="4"
          v-model="createdItem.desc"
          placeholder
        ></el-input>
      </el-form-item>

      <el-form-item label="案件标签">
        <el-select
          v-model="createdItem.tags"
          clearable
          placeholder="请选择案件标签"
          size="small"
        >
          <el-option
            v-for="(label, i) in tags"
            :key="i"
            :label="label"
            :value="i"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="处置建议">
        <el-select
          v-model="createdItem.deal_recommend"
          clearable
          placeholder="请选择处置建议"
          size="small"
        >
          <el-option
            v-for="(label, i) in deal_recommends"
            :key="i"
            :label="label"
            :value="i"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="关联进件ID">
        <el-input
          size="small"
          v-model="createdItem.apply_risk_id"
          placeholder
        ></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button size="small" @click="cancel">取 消</el-button>
      <el-button size="small" type="primary" @click="submit">确 定</el-button>
    </div>
  </el-dialog>
</template>
<script>
export default {
  props: [],
  data() {
    return {
      // 要提交的参数
      createdItem: {},
      deal_recommends: [],
      tags: [],

      // 菜单表单
      loading: false,
      visible: false,
      submiting: false
    }
  },
  methods: {
    show(deal_recommends, tags) {
      ;(this.createdItem = {}), (this.visible = true)
      this.deal_recommends = deal_recommends
      this.tags = tags
    },
    submit() {
      console.log(this.createdItem)

      this.$api.alarm
        .casesCreate({
          data: this.createdItem
        })
        .then(res => {
          console.log(res)
          if (res.data.code === 0) {
            this.visible = false
            this.$emit('close')
          }
        })
        .catch(error => {
          this.$message.error(error)
        })
    },
    cancel() {
      this.visible = false
    }
  }
}
</script>
<style lang="postcss" scoped>
.el-form-item {
  margin-bottom: 5px;
}
</style>
